﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.MiniQuest {
    import flash.events.*;
    import __AS3__.vec.*;
    import Display.*;
    import Modules.franchise.display.*;
    import Modules.franchise.data.*;

    public class FranchiseSaleMQ extends MiniQuest {

        public static const QUEST_NAME:String = "franchiseSaleMQ";

        private var m_needSaleBusinesses:Array;

        public function FranchiseSaleMQ(){
            super(QUEST_NAME);
            this.m_needSaleBusinesses = new Array();
            m_recurrenceTime = 5;
        }
        override protected function onIconClicked(_arg1:MouseEvent):void{
            super.onIconClicked(_arg1);
            this.showFranchiseSale();
            m_recurrenceTime = 0;
        }
        override protected function endQuest():void{
            super.endQuest();
            this.m_needSaleBusinesses = null;
        }
        public function checkFranchiseSales():void{
            var _local2:OwnedFranchiseData;
            var _local3:String;
            if (this.m_needSaleBusinesses.length){
                this.m_needSaleBusinesses = [];
            };
            var _local1:Vector.<OwnedFranchiseData> = Global.franchiseManager.model.getOwnedFranchises();
            for each (_local2 in _local1) {
                if (_local2.locations){
                    for (_local3 in _local2.locations) {
                        if ((((_local2.locations[_local3].commodityLeft == 0)) && (((GlobalEngine.getTimer() / 1000) >= (_local2.locations[_local3].timeLastSupplied + FranchiseMenu.dailyCycleDelta))))){
                            this.m_needSaleBusinesses.push(_local2);
                        };
                    };
                };
            };
        }
        public function get needSaleCount():int{
            return (this.m_needSaleBusinesses.length);
        }
        public function showFranchiseSale():void{
            UI.displayNewFranchise(false);
        }

    }
}//package Classes.MiniQuest 
